home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / srefv12i.zip / sampcook.rxx < prev    next >
Text File  |  1997-01-08  |  1KB  |  41 lines

  1. /* This is a simple demonstration of  the use of cookies with sre-filter.  */
  2. /* To use it, put the following line in your html document:
  3.   <!-- interpret file sampcook.rxx -->
  4. (and be sure this file is in your "goserve working directory") 
  5. */
  6.  
  7. /* If "send in pieces" selected, the adding to header is impossible, so
  8.    we have an ERROR! */
  9. if  send_piece=1 then do
  10.   queue "<strong> ERROR: </strong> SRE-Filter can not set cookies using SSI's "
  11.   queue ' when  <strong> DO_SEND_PIECE="YES" </strong>!'
  12. end
  13.  
  14. else do
  15.  
  16. /* determine if we have a "LAST_ACCESS" cookie */
  17.   tmp.say=sref_get_cookie('LAST_ACCESS',1)
  18.   if tmp.say=' 'then
  19.      tmp.say='This is your first access to  ' docname
  20.   else
  21.     tmp.say=' Last access to ' docname ' was on: ' tmp.say
  22.   queue tmp.say
  23. /* write out all cookies */
  24.   tmp.cookies=reqfield('cookie:')
  25.   queue " <hr> Note that your cookies are: <br> <b> " tmp.cookies "  </b> <p> "
  26.  
  27. /* check on browser */
  28.   tmp.!browser=reqfield('User-agent:')
  29.   tmp.!docook=sref_browser_info('COOKIES')
  30.   if tmp.!docook<>'YES' then
  31.      queue '<br> Our info shows that your browser ('tmp.!browser ') does <b>not</b> understand cookies!<br> '
  32.   else
  33.      queue '<br> Our info shows that your browser ('tmp.!browser ') <b>does</b> understand cookies! <br>'
  34.  
  35.  
  36. /* add a "LAST_ACCESS" cookie for  the invoking URL */
  37.   boo='last_access='||date()' 'time() ' ; path=/'|| docname
  38.   'header add set-cookie: '|| translate(boo,'_',' ')
  39.  
  40. end
  41.